package kevin.framework.basic.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import kevin.framework.basic.dao.IBaseDao;
import kevin.framework.basic.service.impl.BaseService;
import kevin.framework.basic.dao.IRoleDao;
import kevin.framework.basic.domain.Role;

import kevin.framework.basic.service.IRoleService;

/**
*Generate by Kevin's CodeBuilder
**/
@Service
public class RoleService extends BaseService<Role, String> implements IRoleService {

		private static final long serialVersionUID = -1L;

		private  IRoleDao roleDao;

		@Resource(name="roleDao")
		@Override
		public void setDao(IBaseDao<Role, String> dao) {
				this.dao = dao;
				roleDao = (IRoleDao)dao;
		}

		@Override
		public JSONArray getAvailabelRole() throws Exception {
			Map<String,Object> params = new HashMap<String,Object>();
			params.put("roleStatus", 1);
			List<Role> roles = this.selectParam(params);
			JSONArray rolesJson = new JSONArray();
			for(Role r : roles) {
				JSONObject jObj = new JSONObject();
				rolesJson.add(jObj);
				jObj.put("id", r.getId());
				jObj.put("roleName", r.getRoleName());
			}
			return rolesJson;
		}
		
		
		
}
